﻿$(function () {
    $("#myModalsuccess").modal('show');
    $('[data-toggle=offcanvas]').click(function () {
        $('.row-offcanvas').toggleClass('active');
    });

    // $("input").iCheck({
    // checkboxClass: 'icheckbox_square-blue',
    //  increaseArea: '20%' // optional
    // });
    $(".dark input").iCheck({
        checkboxClass: 'icheckbox_polaris',
        increaseArea: '20%' // optional
    });
    $(".form-control").focus(function () {
        $(this).closest(".textbox-wrap").addClass("focused");
    }).blur(function () {
        $(this).closest(".textbox-wrap").removeClass("focused");
    });
    //On Scroll Animations
    if ($(window).width() >= 968 && !Modernizr.touch && Modernizr.cssanimations) {

        $("body").addClass("scroll-animations-activated");
        $('[data-animation-delay]').each(function () {
            var animationDelay = $(this).data("animation-delay");
            $(this).css({
                "-webkit-animation-delay": animationDelay,
                "-moz-animation-delay": animationDelay,
                "-o-animation-delay": animationDelay,
                "-ms-animation-delay": animationDelay,
                "animation-delay": animationDelay
            });
        });
        $('[data-animation]').waypoint(function (direction) {
            if (direction == "down") {
                $(this).addClass("animated " + $(this).data("animation"));
            }
        }, {
            offset: '90%'
        }).waypoint(function (direction) {
            if (direction == "up") {
                $(this).removeClass("animated " + $(this).data("animation"));
            }
        }, {
            offset: $(window).height() + 1
        });
    }
    /*rjs need to be added fr horizntal do not delete
    .waypoint(function (direction) {
    $body.toggleClass(this.id + '-visible', direction === 'left');
    }, {
    offset: '-50%',
    horizontal: true
    })*/
    //End On Scroll Animations
    $(".main-nav a[href]").click(function () {
        var scrollElm = $(this).attr("href");

        $("html,body").animate({ scrollTop: $(scrollElm).offset().top }, 500);

        $(".main-nav a[href]").removeClass("active");
        $(this).addClass("active");
    });
    $("#txtpass").keyup(function () {
        var exp = /^(?=.*\d)(?=.*[a-zA-Z]).{6,20}$/;
        var pass = $(this).val();
        if (!exp.test(pass)) {
            $("#ValidPassContainer").removeClass("has-success");
            $("#ValidPassContainer").addClass("has-error");
            $("#ValidPassContainer label#lblvalidpass").fadeIn();
            $("#txtcpass").attr("disabled", true);
            $("#registerSubmit").attr("disabled", true);
        }
        else {
            $("#ValidPassContainer").addClass("has-success");
            $("#ValidPassContainer label#lblvalidpass").fadeOut();
            $("#txtcpass").attr("disabled", false);
            $("#registerSubmit").attr("disabled", false);
        }
    });
    $("#txtcpass").keyup(function () {
        if ($("#txtpass").val() == "" || $(this).val() == "") {
            $("#passchkContainer label#lblerror").fadeOut();
            $("#passchkContainer label#lblsuccess").fadeOut();
            $("#registerSubmit").attr("disabled", true);
        }
        else if ($("#txtpass").val() == $(this).val()) {
            $("#passchkContainer").addClass("has-success");
            $("#passchkContainer label#lblsuccess").fadeIn();
            $("#passchkContainer label#lblerror").fadeOut();
            $("#registerSubmit").attr("disabled", false);

        } else {
            $("#passchkContainer").addClass("has-error");
            $("#passchkContainer label#lblerror").fadeIn();
            $("#passchkContainer label#lblsuccess").fadeOut();
            $("#registerSubmit").attr("disabled", true);
            //alert("Password Mismatch");
        }
    });
 });